package Q4;

public class Account {
	private double balance; // instance variable that stores the balance

	// constructor
	public Account(double initialBalance) {
		// validate that initialBalance is greater than 0.0;
		// if it is not, balance is initialized to the default value 0.0
		if (initialBalance > 0.0)
			balance = initialBalance;
	} // end Account constructor

	// credit (add) an amount to the account
	public void credit(double amount) {
		balance = balance + amount; // add amount to balance
	} // end method credit

	// Debit an amount from account
	public void debit(double amount) {
		// if it is not, balance will be left unchanged
		if (balance - amount > 10e-5) {
			balance = balance - amount;
		} else {
			System.out.println("Debit amount exceeded account balance.");
		}
	}

	// return the account balance
	public double getBalance() {
		return balance; // gives the value of balance to the calling method
	} // end method getBalance
}
